/**
 * Created by jiangtao on 2017/5/24.
 */

import React , { Component } from 'react';

import {
    Route,
    Switch,

} from 'react-router-dom';


export default class CustomRouter extends Component {
    constructor(){
        super();
    }
    static defaultProps = {
        routers:[]
    };
    render(){
        const { routers } = this.props;
        return(
           <div>
               {routers.map((route, i) => {
                   const exact = route.exact !== undefined  ? route.exact : true;
                   return (
                       <Route exact={exact} path={route.path} key={i} render={ props =>
                           React.cloneElement(route.component, {
                               ...props ,
                               routes:route.children
                           })
                       }/>
                   )
               })}
           </div>
        )

    }
};